Skip to content

feat: Expose ReferenceExpression get value and enhance server value resolution#15138

Merged
IEvangelist merged 5 commits intorelease/13.2from
ref-exp
Mar 12, 2026
Merged

feat: Expose ReferenceExpression get value and enhance server value resolution#15138
IEvangelist merged 5 commits intorelease/13.2from
ref-exp

Conversation

@IEvangelist
Copy link
Copy Markdown
Member

@IEvangelist IEvangelist commented Mar 11, 2026

Expose ReferenceExpression get value and enhance server value resolution

  • Implemented getValue method to resolve the expression's value on the server, including cancellation support.
  • Improved async method handling in CapabilityDispatcher to support ValueTask / ValueTask<T>.
  • Registered handle wrapper for ReferenceExpression in base.ts to avoid duplication in generated SDK.
  • Added tests for ReferenceExpression and ValueTask methods to ensure correct functionality and exports.

Fixes #14772

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

…alue resolution

- Updated ReferenceExpression to support conditional expressions with fields for condition, matchValue, whenTrue, and whenFalse.
- Introduced static method createConditional for creating conditional ReferenceExpressions.
- Implemented getValue method to resolve the expression's value on the server, including cancellation support.
- Registered handle wrapper for ReferenceExpression in base.ts to avoid duplication in generated SDK.
- Added AppHostUsageError for better error handling in capability argument validation.
- Improved async method handling in CapabilityDispatcher to support ValueTask.
- Added tests for ReferenceExpression and ValueTask methods to ensure correct functionality and exports.
Copilot AI review requested due to automatic review settings March 11, 2026 18:36
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 11, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15138

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15138"

@IEvangelist IEvangelist requested review from davidfowl and sebastienros and removed request for Copilot March 11, 2026 18:37
@IEvangelist IEvangelist changed the title feat: Enhance ReferenceExpression with conditional logic and server v… feat: Expose ReferenceExpression get value and enhance server value resolution Mar 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 11, 2026

🎬 CLI E2E Test Recordings

The following terminal recordings are available for commit ab818eb:

Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CreateAndDeployToDockerCompose ▶️ View Recording
CreateAndDeployToDockerComposeInteractive ▶️ View Recording
CreateAndPublishToKubernetes ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateEmptyAppHostProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #22985137955

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the Aspire polyglot/ATS experience by enabling server-side resolution of ReferenceExpression values from the generated TypeScript SDK and by extending the RemoteHost capability dispatcher to correctly handle ValueTask-based capability methods.

Changes:

  • Exported ReferenceExpression.GetValueAsync(...) as an ATS capability and added a TypeScript ReferenceExpression.getValue(...) helper (with cancellation support) plus a centralized handle-wrapper registration in base.ts.
  • Refactored CapabilityDispatcher async result handling to unwrap Task, ValueTask, and ValueTask<T>, and added tests for ValueTask<T> capabilities.
  • Updated the TypeScript code generator to avoid generating a duplicate ReferenceExpression wrapper when it’s implemented manually in base.ts, and added tests to enforce this.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Aspire.Hosting.RemoteHost.Tests/CapabilityDispatcherTests.cs Adds coverage for invoking ValueTask<T> capabilities (static + instance).
tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/AtsTypeScriptCodeGeneratorTests.cs Adds tests ensuring ReferenceExpression wrapper stays in base.ts and getValueAsync is exported.
src/Aspire.Hosting/ApplicationModel/ReferenceExpression.cs Exposes GetValueAsync via [AspireExport] for polyglot access.
src/Aspire.Hosting.RemoteHost/Ats/CapabilityDispatcher.cs Centralizes async unwrapping and adds ValueTask/ValueTask<T> support.
src/Aspire.Hosting.CodeGeneration.TypeScript/Resources/base.ts Adds ReferenceExpression.getValue(...) and registers a handle wrapper in base.ts.
src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs Skips generating a duplicate ReferenceExpression wrapper class in aspire.ts.
playground/TypeScriptAppHost/.modules/transport.ts Adds argument validation (detecting Promise-like args) before capability invocation.
playground/TypeScriptAppHost/.modules/base.ts Syncs the playground SDK base types with new getValue(...) and wrapper registration.
playground/TypeScriptAppHost/.modules/aspire.ts Updates generated playground SDK exports/behavior (including AppHostUsageError handling).

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Copy Markdown
Contributor

@sebastienros sebastienros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably change getValue first

@IEvangelist IEvangelist enabled auto-merge (squash) March 12, 2026 02:27
@github-actions
Copy link
Copy Markdown
Contributor

The transient CI rerun workflow requested reruns for the following jobs after analyzing the failed attempt.
GitHub's job rerun API also reruns dependent jobs, so the retry is being tracked in the rerun attempt.
The job links below point to the failed attempt that matched the retry-safe transient failure rules.

The ReferenceExpression class now exports a getValue capability via
[AspireExport("getValue")], so the generated Python SDK must include
the corresponding get_value method instead of a bare pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@IEvangelist IEvangelist merged commit 8013120 into release/13.2 Mar 12, 2026
814 of 842 checks passed
@IEvangelist IEvangelist deleted the ref-exp branch March 12, 2026 11:57
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants